<!--
 * @Author: suxunying
 * @desc: 
 * @Date: 2021-07-26 09:17:41
 * @LastEditors: suxunying
 * @LastEditTime: 2021-07-26 11:03:59
 * @FilePath: \bmp-poc\plat\src\App.vue
-->
<!--
 * @Author: suxunying
 * @desc: 
 * @Date: 2021-07-26 09:17:41
 * @LastEditors: suxunying
 * @LastEditTime: 2021-07-26 10:18:53
 * @FilePath: \bmp-poc\plat\src\App.vue
-->
<template>
  <div id="app">
      <h2>plat</h2>
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
      <p>
          <span>username:</span>
          <input v-model="username"/>
          <button @click="handleSubmit">submit</button>
      </p>
      <p>
          userinfo: {{ userinfo }}
      </p>
      <p>
          language: {{ locale }}
          <button @click="handleChange">change</button>
      </p>
    <div id="nav">
        <router-view/>
    </div>
    
  </div>
</template>
<script>
import { mapGetters } from 'vuex';

export default {
    data() {
        return {
            username: '',
        };
    },
    computed: {
        ...mapGetters(['userinfo', 'locale']),
    },
    methods: {
        handleSubmit() {
            const userinfo = {
                username: this.username,
            };
            this.$store.dispatch('getInfo', userinfo);
        },
        handleChange() {
            let locale = ''
            if (this.locale === 'zh') {
                locale = 'en';
            } else {
                locale = 'zh';
            }
            this.$store.dispatch('setLocale', locale);
        }
    },
};
</script>
<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
